﻿<?xml version="1.0" encoding="utf-8" ?>
<DbDataRequest connection="$ForumDBConnection$" type="$ForumDBType$">
  <SqlStatement hasResults="false">
    SET @dateCreated = GetDate();
    INSERT INTO ThreadPosts(id,threadId, title,description, dateCreated, createdById, createdByName)
    VALUES(@postId, @threadId, @title, @description, @dateCreated, @createdById, @createdByName);

    UPDATE ForumThreads SET
      lastPostById=@createdById,lastPostByName=@createdByName,
      lastPostDate=@dateCreated,totalPosts=totalPosts+1
    WHERE id=@threadId;

    UPDATE Forum SET
      numPost=numPost+1,lastPostTitle=@shortTitle,lastPostById=@createdById,
      lastPostByName=@createdByName,lastPostDate=@dateCreated
    WHERE id=@forumId;

  </SqlStatement>
  <Param name="id" dbName="postId" type="UniqueIdentifier" />
  <Param name="threadId" type="UniqueIdentifier" />
  <Param name="forumId" type="UniqueIdentifier" />
  <Param name="title" type="VarChar" />
  <Param name="shortTitle" type="VarChar" />
  <Param name="description" type="VarChar" />
  <Param name="dateCreated" type="DateTime" />
  <Param name="createdBy.id" dbName="createdById" type="UniqueIdentifier"/>
  <Param name="createdBy.userName" dbName="createdByName" type="VarChar" />
</DbDataRequest>